import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author gao
 * @date 2025/9/16 9:13
 */

public class Solution {
    public int numSubarraysWithSum(int[] nums, int goal) {
        Map<Integer, Integer> hashMap = new HashMap<>();
        // 初始化，前缀和为0的情况出现1次
        hashMap.put(0, 1);
        int count = 0, sum = 0;

        for (int i : nums) {
            // 计算当前前缀和
            sum += i;
            if (hashMap.containsKey(sum - goal)) {
                count += hashMap.get(sum - goal);
            }
            // 更新哈希表中当前前缀和的出现次数
            hashMap.put(sum, hashMap.getOrDefault(sum, 0) + 1);
        }
        return count;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < nums.length; i++) {
                nums[i] = in.nextInt();
            }
            int goal = in.nextInt();
            Solution solution = new Solution();
            System.out.println(solution.numSubarraysWithSum(nums, goal));
        }
    }
}